import axios from "axios";
import React, { Component } from "react";
import "./Hero.css";
import HeroSearch from "../HeroSearch/HeroSearch";
import HeroList from "../HeroList/HeroList";
export default class Hero extends Component {
    
    render() {
        return (
            <div className="hero-container">
                <h2>英雄列表</h2>
                <hr />
                <HeroSearch />
                <hr />
                <HeroList />
            </div>
        );
    }

    //搜索功能
    search = async () => {
        //获取关键字的内容
        let keyword = this.input.value;
        //发送 AJAX 请求
        // let result = await axios.get('http://api.xiaohigh.com/heros?q=' + keyword);
        let result = await axios.get('http://api.xiaohigh.com/heros', {
            params: {
                q: keyword
            }
        });
        //查看结果
        this.setState({
            heros: result.data
        })
    }

    
}
